﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Windows.Controls.Ribbon;
using Microsoft.Practices.Composite.Events;
using PJ.Presentation;
using PJ.Framework.Common;
using PJ.Business.SalePurchase;
using PJ.Business.SalePurchase.Sale;
using PJ.Presentation.SalePurchase.Sale;

namespace PJ.AppPOS
{
    /// <summary>
    /// Logique d'interaction pour Window1.xaml
    /// </summary>
    public partial class Shell : Window
    {
        public Shell()
        {
            InitializeComponent();
        }

        public Microsoft.Practices.Unity.IUnityContainer Container;

        private void rcbThemes_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.rcbThemes.SelectedItem != null)
            {
                var theme = this.rcbThemes.SelectedItem as RibbonComboBoxItem;
                if (theme != null)
                {
                    var rd = this.Resources.MergedDictionaries[0];
                    rd.Source = new Uri(string.Format("pack://application:,,,/RibbonControlsLibrary;component/Themes/{0}.xaml", theme.Content));
                }
            }
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (Container != null)
                Container.Resolve<IEventAggregator>().GetEvent<ApplicationCloseEvent>().Publish(false);
        }

        private void RibbonCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            InjectionBroker.Resolve<EventAggregator>().GetEvent<PostInvoiceEvent>().Publish(null);
        }
    }
}
